Skip to content

feat: add retentionPolicy in storage migration plan#2683

Open
duyanyan wants to merge 1 commit intoRedHatQE:mainfrom
duyanyan:retetion_policy
Open

feat: add retentionPolicy in storage migration plan#2683
duyanyan wants to merge 1 commit intoRedHatQE:mainfrom
duyanyan:retetion_policy

Conversation

@duyanyan
Copy link
Copy Markdown
Contributor

@duyanyan duyanyan commented Mar 27, 2026

Short description:

Add retentionPolicy in storage migration plan resources

More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
Bug:

Summary by CodeRabbit

  • New Features
    • Added optional retention policy for virtual machine storage migration plans. Users can now set a retention policy (optional) for both single-namespace and multi-namespace migration plans; the policy is included in plan definitions only when provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9b3d7fc2-b4fb-4448-b662-02fdbf84904e

📥 Commits

Reviewing files that changed from the base of the PR and between 061a4b6 and 664affc.

📒 Files selected for processing (2)
  • ocp_resources/multi_namespace_virtual_machine_storage_migration_plan.py
  • ocp_resources/virtual_machine_storage_migration_plan.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • ocp_resources/virtual_machine_storage_migration_plan.py
  • ocp_resources/multi_namespace_virtual_machine_storage_migration_plan.py

Walkthrough

Two resource migration plan classes (MultiNamespaceVirtualMachineStorageMigrationPlan and VirtualMachineStorageMigrationPlan) now accept an optional retention_policy constructor parameter; when set, it is stored and conditionally added to the generated resource spec during serialization.

Changes

Cohort / File(s) Summary
Storage Migration Plan Retention Policy Support
ocp_resources/multi_namespace_virtual_machine_storage_migration_plan.py, ocp_resources/virtual_machine_storage_migration_plan.py
Added optional retention_policy: str | None constructor parameter to both classes, stored on the instance, and conditionally included as spec["retentionPolicy"] in to_dict() when not None. Constructor signatures updated accordingly.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description provides only a short description; the more detailed sections (More details, What this PR does / why we need it, Which issue(s) this PR fixes, Special notes for reviewer, Bug) are empty. Complete the description by filling in the remaining template sections, especially explaining what the PR does, why it's needed, and which issue it fixes.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding retentionPolicy support to storage migration plan resources.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@redhat-qe-bot
Copy link
Copy Markdown
Contributor

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest python-module-install - Test Python package installation
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. Status Checks: All required status checks must pass
  3. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  4. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • rnetser

Reviewers:

  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge
AI Features
  • Conventional Title: Mode: fix (claude/claude-opus-4-6[1m])
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6[1m])

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@redhat-qe-bot redhat-qe-bot requested a review from myakove March 27, 2026 06:41
@redhat-qe-bot redhat-qe-bot requested a review from rnetser March 27, 2026 06:41
@redhat-qe-bot redhat-qe-bot changed the title Add retentionPolicy in storage migration plan resources feat: add retentionPolicy in storage migration plan Mar 27, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ocp_resources/virtual_machine_storage_migration_plan.py (1)

20-49: ⚠️ Potential issue | 🟠 Major

Direct edits were made in generated resource code; move this change to the generator.

These updates are inside the generated section. Please implement retention_policy support in the class-generator source/template and regenerate this resource file, rather than maintaining manual edits here.

As per coding guidelines, code in **/ocp_resources/** between generated markers must not be edited directly; update the class-generator instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ocp_resources/virtual_machine_storage_migration_plan.py` around lines 20 -
49, The retention_policy change was made directly in the generated resource;
instead update the class-generator/template so this field is generated. Modify
the generator to add a retention_policy: str | None parameter to the resource
constructor (alongside virtual_machines), assign it to self.retention_policy,
and ensure to_dict emits _spec["retentionPolicy"] when self.retention_policy is
not None (same pattern used for virtual_machines and
MissingRequiredArgumentError checks); then regenerate
ocp_resources/virtual_machine_storage_migration_plan.py so the manual edits are
removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ocp_resources/virtual_machine_storage_migration_plan.py`:
- Around line 20-49: The retention_policy change was made directly in the
generated resource; instead update the class-generator/template so this field is
generated. Modify the generator to add a retention_policy: str | None parameter
to the resource constructor (alongside virtual_machines), assign it to
self.retention_policy, and ensure to_dict emits _spec["retentionPolicy"] when
self.retention_policy is not None (same pattern used for virtual_machines and
MissingRequiredArgumentError checks); then regenerate
ocp_resources/virtual_machine_storage_migration_plan.py so the manual edits are
removed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 55d6ea3f-6353-4115-b313-f000bb1dcb77

📥 Commits

Reviewing files that changed from the base of the PR and between d5e07db and 061a4b6.

📒 Files selected for processing (2)
  • ocp_resources/multi_namespace_virtual_machine_storage_migration_plan.py
  • ocp_resources/virtual_machine_storage_migration_plan.py

Comment on lines 26 to 31
Each namespace item can contain:
- name (str): Namespace name
- retentionPolicy (str, optional): Namespace-level retention policy (e.g., 'keepSource' or 'deleteSource')
- virtualMachines (list): VMs to migrate
retention_policy (str, optional): Spec-level retention policy for source volumes (e.g., 'keepSource' or 'deleteSource').

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you generate the resource using class-generator?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, but I have updated the code with class-generator, please review again

r"""
Args:
virtual_machines (list[Any]): The virtual machines to migrate.
retention_policy (str, optional): Spec-level retention policy for source volumes (e.g., 'keepSource' or 'deleteSource').
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants